﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Demo.Services.Contracts.DTO.Infos;
using Demo.CommonBase.DTO.Infos;
using Demo.Services.Contracts.DTO.Filters;
using Demo.Services.Integration.DAO.Impl;
using Demo.CommonBase.Logging;
using Demo.CommonBase.Exceptions;
using System.Reflection;

namespace Demo.Services.Services.Impl.DomainObjects
{
    public class AreaDomainObject
    {
        public AreaResultInfo GetAreas(PaginationInfo pagin, AreaFilter filters)
        {
            AreaResultInfo result = null;
            AreaDAO areaDao;
            try
            {
                //Logger.Info();
                areaDao = new AreaDAO();
                result = areaDao.GetAreas(pagin, filters);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
            return result;
        }

        public AreaInfo GetAreaById(int id)
        {
            AreaInfo result = null;
            AreaDAO areaDao;
            try
            {
                //Logger.Info();
                areaDao = new AreaDAO();
                result = areaDao.GetAreaById(id);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
            return result;
        }
        public void DeleteArea(int id)
        {
            AreaDAO areaDao;
            try
            {
                //Logger.Info();
                areaDao = new AreaDAO();
                areaDao.DeleteArea(id);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
        }
        public void UpdateArea(AreaInfo area)
        {
            AreaDAO areaDao;
            try
            {
                //Logger.Info();
                areaDao = new AreaDAO();
                areaDao.UpdateArea(area);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
        }
        public void SaveArea(AreaInfo area)
        {
            AreaDAO areaDao;
            try
            {
                //Logger.Info();
                areaDao = new AreaDAO();
                areaDao.SaveArea(area);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
        }
        public bool CheckName(int id, string name)
        {
            bool isValid = false;
            AreaDAO areaDao;
            try
            {
                Logger.Info();
                areaDao = new AreaDAO();
                isValid = areaDao.CheckName(id, name);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
            return isValid;
        }

    }
}
